package com.alibaba.nacos.plugin.datasource.dialect;

import com.alibaba.nacos.plugin.datasource.constants.DatabaseTypeConstant;

public class Kingbase8DatabaseDialect extends AbstractDatabaseDialect {

	@Override
	public String getType() {
		return DatabaseTypeConstant.KINGBASE8;
	}
	
	@Override
	public String getLimitTopSqlWithMark(String sql) {
		return sql + " FETCH FIRST ? ROWS ONLY ";
	}
	
	@Override
	public String getLimitPageSqlWithMark(String sql) {
		return sql + " OFFSET ? ROWS FETCH NEXT ? ROWS ONLY ";
	}
	
	@Override
	public String getLimitPageSqlWithOffset(String sql, int startOffset, int pageSize) {
		return sql + "  OFFSET " + startOffset + " ROWS FETCH NEXT " + pageSize + " ROWS ONLY ";
	}
	
	@Override
	public String getLimitPageSql(String sql, int pageNo, int pageSize) {
		return sql + "  OFFSET " + getPagePrevNum(pageNo, pageSize) + " ROWS FETCH NEXT " + pageSize + " ROWS ONLY ";
	}
}
